<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Excel 上传</title>
<style>
.cl{width:95%; margin:60px auto;}
.ans{ width:1200px; margin:60px auto;}
</style>
    <script src="/cn/js/jquery-1.12.2.min.js"></script>
<script type="text/javascript" src="/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="/ueditor/ueditor.all.min.js"></script>
<!-- 编辑器公式插件 -->
<script type="text/javascript" charset="utf-8" src="/ueditor/kityformula-plugin/addKityFormulaDialog.js"></script>
<script type="text/javascript" charset="utf-8" src="/ueditor/kityformula-plugin/getKfContent.js"></script>
<script type="text/javascript" charset="utf-8" src="/ueditor/kityformula-plugin/defaultFilterFix.js"></script>
<script type="text/javascript" src="/My97DatePicker/WdatePicker.js"></script>
</head>
<body>
<!-- 百度编辑 -->
<input type="text" value="<input/>">
<input type="text" value="<img/>">
<input type="text" value="<link/>">
<div id="wrapper" class="cl">
    <form action="">
        <div class="controls">
            百度编辑
            <textarea  id="editor" class="editor"
            name="value"></textarea>
            <script>var editor = UE.getEditor('editor');</script>
            <input type="hidden" name="kye" value="">
        </div>
        <button type="button" class="update">开始生成</button>
        <button type="button" class="update2">开始生成（听力）</button>
    </form>
</div>
<div  class="ans">
    原格式输出内容
<div>

<script type="text/plain" id="j_ueditorupload"></script>
</body>
</html>

<script>
// 提交数据到数据库  -列表
$(".update").click(function(){

    // document.getElementById("editor") = editor; 
    // '赋值给textarea
    // 带格式
    var text = editor.getContent();
    if(text){
        $('.ans').text(text);        
    }
    // 纯文本
    // var txt = editor.getContentTxt();
    // console.log(txt);
    // if(url){
    //     // alert(111);
    //     $.ajax({
    //     type: 'post',
    //     data: {url:url},
    //     // data: $('#form1').serialize(),
    //     url: '/cn/apiexcel/updatetypelist',
    //     dataType: 'json',
    //     success: function(data){   
    //         alert('数据上传成功');
    //     }
    // })
    // }else{
    //     alert("请选择上传文件");
    // }
});

$(".update2").click(function(){

    // 带格式
    var text = editor.getContent();
    if(text){
        var reg = /style=\"(.*?)\"/gi;
        text = text.replace(/<input(.*?)\/>/ig,'<input/>');
        text = text.replace(/<div(.*?)>/ig,'<div>');
        text = text.replace(/<p(.*?)>/ig,'<p>');
        text = text.replace(reg,'');
        $('.ans').text(text);
    }
});
</script>
<script>
//实例化编辑器
var o_ueditorupload = UE.getEditor('j_ueditorupload',
    {
        autoHeightEnabled: false
    });
o_ueditorupload.ready(function () {

    o_ueditorupload.hide();//隐藏编辑器

    o_ueditorupload.addListener('afterUpfile', function (t, arg) {
        $('.file').val(arg[0].url);
    });
});

// 弹出文件上传的对话框
function upFiles() {
    var myFiles = o_ueditorupload.getDialog("attachment");
    myFiles.open();
}
</script>
<!-- <script>
    //实例化编辑器
    var o_ueditorupload = UE.getEditor('j_ueditorupload',
        {
            autoHeightEnabled:false
        });
    o_ueditorupload.ready(function ()
    {

        o_ueditorupload.hide();//隐藏编辑器

        //监听图片上传
        o_ueditorupload.addListener('beforeInsertImage', function (t,arg)
        {
            $('.imageFile').val(arg[0].src);

        });
        /* 文件上传监听
         * 需要在ueditor.all.min.js文件中找到
         * d.execCommand("insertHtml",l)
         * 之后插入d.fireEvent('afterUpfile',b)
         */
        o_ueditorupload.addListener('afterUpfile', function (t, arg)
        {
            // $('.file1').val(arg[0].url);
            // console.log($('.file').val(arg[0].url));
        });
    });

    //弹出图片上传的对话框
    // function upImage()
    // {
    //     var myImage = o_ueditorupload.getDialog("insertimage");
    //     myImage.open();
    // }
    //弹出文件上传的对话框  --列表
       function upFiles1()
       {
           var myFiles = o_ueditorupload.getDialog("attachment");
           myFiles.open();
           o_ueditorupload.addListener('afterUpfile', function (t, arg)
        {
            $('.file1').val(arg[0].url);
            // console.log($('.file').val(arg[0].url));
        });
       }


    //弹出文件上传的对话框 --单词
    function upFiles2() 
       {
           var myFiles = o_ueditorupload.getDialog("attachment");
           myFiles.open();
           o_ueditorupload.addListener('afterUpfile', function (t, arg)
        {
            $('.file2').val(arg[0].url);
            // console.log($('.file').val(arg[0].url));
        });
       }

</script> -->
<!-- <script type="text/plain" id="j_ueditorupload"></script> -->




